package com.lyn.chapter2.demo2;

import com.lyn.kit.Tools;

public class ThreadStartVisibility {
	//线程间的共享变量
	static int data  = 0;
	public static void main(String[] args) {
		Thread thread = new Thread() {
			@Override
			public void run() {
				//线程随机休眠N秒
				Tools.randomPause(50);
				System.out.println(data); //1
			}
		};
		//在子线程thread启动之前更新变量data的值
		data = 1;
		thread.start();
		Tools.randomPause(50);
		//在子线程thread启动后更新变量data的值
		data = 2;
	}
}
